<template>
    <view class="loading-container" @touchmove.stop.prevent="trueFun" v-if="loadingState">
        <view class="loading-mask" v-if="maskState"></view>
        <view class="loading-main">
            <view class="loading-content">
                <view class="loading-image">
                    <image src="/static/images/loading.png"></image>
                </view>
                <view class="loading-text">
                    {{ loadingText }}
                </view>
            </view>
        </view>
    </view>
</template>

<script>
export default {
    data() {
        return {
            loadingState: true,
            maskState: true,
            loadingText: '加载中...'
        };
    },
    /**
     * 组件的属性列表
     */
    props: {},
    /**
     * 组件的方法列表
     */
    methods: {
        show({ mask = false, title = '加载中...' } = {}) {
            this.setData({
                loadingState: true,
                maskState: mask,
                loadingText: title
            });
        },

        hide() {
            this.setData({
                loadingState: false
            });
        },

        trueFun() {
            ////console.log('占位：函数 true 未声明');
        }
    },
    created: function () {}
};
</script>
<style>
view,
page,
text {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
.loading-container {
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 999999;
}
.loading-container .loading-mask {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 9;
    background-color: rgba(0, 0, 0, 0.5);
}
.loading-container .loading-main {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 99;
}
.loading-container .loading-main .loading-content {
    width: 250rpx;
    height: 250rpx;
    border-radius: 20rpx;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
}
.loading-container .loading-main .loading-content .loading-image {
    width: 150rpx;
    height: 150rpx;
    padding: 40rpx;
    margin-top: 10rpx;
}
.loading-container .loading-main .loading-content .loading-image image {
    width: 100%;
    height: 100%;
    animation: loading 1s linear infinite;
}
@keyframes loading {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}
.loading-container .loading-main .loading-content .loading-text {
    width: 100%;
    padding: 0rpx 20rpx;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #fff;
}
</style>
